<?php
if (!isset($_GET['code']) || $_GET['code'] != 'yingyingisgod') {
	die('hello');
}
require_once 'medoo.php';

$database = new medoo(MYSQL_DATABASE);

    $datas = $database->select("coolpad201402", array ('id', 'mobile', 'email', 'date'));
    
    $output = '';
    $header = '';
    $content = '';
    $header = '"id","mobile","email","date"' . "\r\n";
    
    
    foreach($datas as $data) {
    	$content .= '"' . $data['id'] . '","' . $data['mobile'] . '","' . $data['email'] . '","' . $data['date'] . '",' . "\r\n";
    }
    
    $output = $header . $content;
    
    header("Content-type: text/plain; charset=UTF-8");
    header("Content-Disposition: attachment; filename=coolpad" . time() . ".csv");
    header("Pragma: no-cache");
    header("Expires: 0");
    print $output;
    exit();

?>